package com.zide.ams.controller;

import java.util.List;

import com.zide.ams.domain.vo.result.AmsLikeResultVO;
import com.zide.ams.domain.vo.save.AmsLikeSaveVO;
import com.zide.ams.domain.vo.search.AmsLikeSearchVO;
import com.zide.ams.service.IAmsLikeService;
import com.zide.common.core.vo.CommonParamIdVO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zide.common.core.domain.PageResult;
import com.zide.common.core.domain.CommonResult;
import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * 文章点赞Controller
 * 
 * @author zide
 * @date 2024-05-08
 */
@Tag(name = "文章点赞")
@RestController
@RequestMapping("/ams/like")
public class AmsLikeController {
    @Resource
    private IAmsLikeService amsLikeService;

    @Operation(summary = "查询文章点赞列表")
    @GetMapping("/list")
    public CommonResult list(AmsLikeSearchVO searchVO) {

        PageResult<AmsLikeResultVO> list = amsLikeService.searchAmsLikePageList(searchVO);
        return success(list);
    }

    @Operation(summary = "新增文章点赞")
    @PostMapping
    public CommonResult add(@RequestBody @Valid AmsLikeSaveVO saveVO) {
        return getResult(amsLikeService.saveAmsLike(saveVO));
    }


    @Operation(summary = "删除文章点赞")
	@DeleteMapping
    public CommonResult cancelLike(@RequestBody @Valid AmsLikeSaveVO saveVO){
        return getResult(amsLikeService.cancelLike(saveVO));
    }
}
